package user_wash

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/client/userwash"
	"github.com/jinzhu/copier"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserWashDescListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 洗码描述--描述列表
func NewUserWashDescListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserWashDescListLogic {
	return &UserWashDescListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserWashDescListLogic) UserWashDescList(req *types.UserWashDescListRequest) (resp *types.UserWashDescListResponse, err error) {
	resp = &types.UserWashDescListResponse{
		Data: []types.UserWashDescListPageResponse_Data{},
		Meta: types.UserWashDescListPageResponse_Meta{},
	}

	userWashList, err := l.svcCtx.AssetsRpc.UserWash.UserWashDescList(l.ctx, &userwash.UserWashDescListRequest{
		Language: req.Language,
		Page:     req.Page,
		PageSize: req.PageSize,
	})
	if err != nil {
		return nil, err
	}

	copier.Copy(&resp.Data, &userWashList.List)
	copier.Copy(&resp.Meta, &userWashList.Meta)
	return
}
